package com.yuhang.demo;

import com.alibaba.fastjson.JSON;
import com.yuhang.demo.util.OrderPayDto;
import com.yuhang.demo.util.PayType;
import com.yuhang.demo.util.PostUtil;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class NewPayTest {

    public static String api = "http://127.0.0.1:8080/";


    public static void main(String[] args) throws IOException {
       String result =  orderPay();

        System.out.println(result);
    }

    public static String orderPay() throws IOException {
        String url = api + "/payment/orderPay";
        OrderPayDto dto = new OrderPayDto();
        dto.setPwd("123456");
        dto.setType(PayType.ALIPAY);
        dto.setUserId(278569L);//502850L
//		dto.setAmount("197"); //910.44 68
        dto.setAmount("38.9"); //910.44 68
        List<Long> list = new ArrayList<Long>();
        list.add(6377047L);
        //1195.49
        dto.setOrders(list);
        dto.setRate("0.5");
        List<NameValuePair> formparams = new ArrayList<NameValuePair>();
        formparams.add(new BasicNameValuePair("json", JSON.toJSONString(dto)));
        return PostUtil.httpPost(url, formparams);
    }
}
